import React, { useState, useEffect } from 'react';
import { View, StyleSheet, Text, Linking, Button } from 'react-native';

import DemoContainer from '@common/demoContainer';

export default function App({ route }: any) {
    const { params = {} } = route;
    const [count, setCount] = useState(0);
    useEffect(() => {
        const listener = Linking.addEventListener('url', () => {
            setCount(count + 1);
        })
        return () => {
            listener.remove();
        }
    })
    return (
        <DemoContainer params={params}>
            <View style={styles.container}>
                <Button title={t('api.Linking.addEventListener.resetCount')} onPress={() => setCount(0)}></Button>
                <Text style={styles.textStyle}>{t('api.Linking.addEventListener.triggerCountText', { count })}</Text>
            </View>
        </DemoContainer>
    );
}

const styles = StyleSheet.create({
    container: {
    },
    textStyle: {
        fontSize: 16, // 增大字体大小
        fontWeight: 'bold', // 加粗字体
        color: '#333', // 设置字体颜色
        textAlign: 'center', // 文本居中
    }
});
